<#assign module="zhuanxian"/>
<@override name="header">
    <link rel="stylesheet" href="${ctx}/assets/css/chosen.min.css">
    <style>
        .chosen-container {
            font-size: 14px;
            min-width: 370px;
        }
    </style>
    <style>
        /* autocomplete */
        div.ac {
            border: 1px solid #ccc;
            position: absolute;
            display: none;
            overflow: auto;
            background-color: #ffffff;
            z-index: 999999;
        }

        div.ac > ul {
            margin-top: 10px;
            padding: 0;
        }

        div.ac > ul > li {
            height: 33px;
            line-height: 33px;
            cursor: pointer;
        }

        div.ac > ul > li:hover {
            background: #eee;
        }

        div.ac > ul > li > div span {
            padding-left: 15px;
        }

        div.ac > ul > li > div span em {
            color: red;
            font-style: normal;
        }
    </style>
</@override>
<@override name="body">

    <div class="tabbable tabs-left">
        <div class="row">
            <div class="col-xs-12">
                <div class="orders-navt">
                    <ul class="orders-nav">
                        <@shiro.hasPermission name='zhuanxianCar'>
                            <li><a href="${ctx}/zhuanxian/cars">车辆</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='zhuanxianLine'>
                            <li class="orders-click"><a data-toggle="tab" href="${ctx}/zhuanxian/lines"
                                                        class="orders-click-a">线路</a></li>
                        </@shiro.hasPermission>
                    </ul>
                </div>
                <div class="orders-navh">
                    <button class="pull-right btn btn-primary addLine"><i class="icon-plus"></i>&nbsp;添加线路</button>
                </div>
            </div>
        </div>
    </div>

    <div class="tab-content">
        <div class="container-fluid ">
            <@shiro.isMainCompany>
                <div class="row query-pad">
                    <div class="col-xs-11" style="padding: 0px;">
                        <div class="col-xs-4 input-query">
                            <span>所属公司:</span>
                            <input type="text" class="form-control form-contb" id="companyName" name="companyName"
                                   placeholder="请输入公司名字"/>
                        </div>

                    </div>
                    <div class="col-xs-1" style="padding: 0px;">
                        <div class="input-query-bttom">
                            <button id="searchButton" type="button">查询</button>
                        </div>
                    </div>
                </div>
            </@shiro.isMainCompany>
            <br/>
        </div>
    </div>

    <!--列表-->
    <div class="tabta-content">
        <table class="table table-condensed table-striped">
            <tbody id="line_tbody">
            <tr>
            <tr>
                <th class="">线路名</th>
                <@shiro.isMainCompany>
                    <th class="">所属公司</th>
                </@shiro.isMainCompany>
                <th class="">开始城市</th>
                <th>开始地区</th>
                <th>结束城市</th>
                <th>结束地区</th>
                <th>拼车收费</th>
                <th>包车收费</th>
                <th>寄货 收费</th>
                <th>联系电话</th>
                <th class="col-xs-1">操作</th>
            </tr>
            </tr>
            </tbody>
        </table>

        <ul class="pagination pull-left pagination-sm pageshow" style="display:none;">
            <li><a></a></li>
        </ul>
        <ul class="pagination pull-left pagination-sm pagedata" style="display:none;">
        </ul>
    </div>

    <!--添加线路-->
    <div class="form-horizontal">
        <div class="modal fade" id="dialog_line">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">添加线路</h4>
                    </div>
                    <div class="modal-body">
                        <form action="" method="post">
                            <@shiro.isMainCompany>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">所属公司:</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" id="companyId">
                                            <#if companys??>
                                                <#list companys as company>
                                                    <option value="${company.id}"
                                                            <#if companyId?? && companyId==company.id>selected="selected"</#if>>${company.abbreviation?if_exists}</option>
                                                </#list>
                                            </#if>
                                        </select>
                                    </div>
                                </div>
                            </@shiro.isMainCompany>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">线路名:</label>
                                <div class="col-sm-8">
                                    <input id="firstName" class="form-control" style="width: 175px; display: inline-block" placeholder="起始地"/>
                                    <span>&nbsp;-&nbsp;</span>
                                    <input id="lastName" class="form-control"style="width: 175px; display: inline-block" placeholder="目的地"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">开始城市:</label>
                                <div class="col-sm-8">
                                    <select class="form-control" style="width:49%;display:inline-block" id="prov"
                                            required></select>
                                    <select class="form-control" style="width:49%;display:inline-block" id="city"
                                            required></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">开始地址:</label>
                                <div class="col-sm-8">
                                    <input id="startAddress" class="form-control" autocomplete="off" type="text"></input>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">目的地城市:</label>
                                <div class="col-sm-8">
                                    <select class="form-control" style="width:49%;display:inline-block" id="end_prov"
                                            required></select>
                                    <select class="form-control" style="width:49%;display:inline-block" id="end_city"
                                            required></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">目的地地址:</label>
                                <div class="col-sm-8">
                                    <input id="endAddress" class="form-control"></input>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">拼车收费:</label>
                                <div class="col-sm-8">
                                    <!--<input type="hidden" id="areaId">
                                    <input type="text" class="form-control" id="areaId_input" placeholder="请输入收费标准名称"  autocomplete="off"/>-->
                                    <select id="areaId_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">包车收费:</label>
                                <div class="col-sm-8">
                                    <!--<input type="hidden" id="baocheAreaId">
                                    <input type="text" class="form-control" id="baocheAreaId_input" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                                    <select id="baocheAreaId_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">寄货收费:</label>
                                <div class="col-sm-8">
                                    <!--<input type="hidden" id="jihuoAreaId">
                                    <input type="text" class="form-control" id="jihuoAreaId_input" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                                    <select id="jihuoAreaId_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话:</label>
                                <div class="col-sm-8">
                                    <input id="contactNumber" class="form-control" placeholder="选填！"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">角色权限:</label>
                                <div class="col-sm-8">
                                    <#if roles?exists>
                                        <#list roles as role>
                                            <label style="padding-right:5px;">
                                                <input type="checkbox" name="roleInput" class="roleInput" value="${role.id}"/>${role.name}
                                            </label>
                                        </#list>
                                    </#if>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                </div>
                                <div class="col-sm-3">
                                    <input type="button" class="btn btn-primary" id="save" value="确定">
                                    <button type="button" class="btn btn-default" data-dismiss="modal"
                                            id="close_modal_memo">关闭
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--编辑路线-->
    <div class="form-horizontal">
        <div class="modal fade" id="dialog_line_update">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">编辑路线</h4>
                    </div>
                    <div class="modal-body">
                        <form action="" method="post">
                            <input type="hidden" id="lineId2"/>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">线路名:</label>
                                <div class="col-sm-8">
                                    <input id="name2" class="form-control"></input>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">开始城市:</label>
                                <div class="col-sm-8">
                                    <select class="form-control" style="width:49%;display:inline-block" id="prov2"
                                            required></select>
                                    <select class="form-control" style="width:49%;display:inline-block" id="city2"
                                            required></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">开始地址:</label>
                                <div class="col-sm-8">
                                    <input id="startAddress2" class="form-control"></input>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">目的地城市:</label>
                                <div class="col-sm-8">
                                    <select class="form-control" style="width:49%;display:inline-block" id="end_prov2"
                                            required></select>
                                    <select class="form-control" style="width:49%;display:inline-block" id="end_city2"
                                            required></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">目的地地址:</label>
                                <div class="col-sm-8">
                                    <input id="endAddress2" class="form-control"></input>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">拼车收费:</label>
                                <div class="col-sm-8">
                                    <!--
                                    <input type="hidden" id="areaId2">
                                    <input type="text" class="form-control" id="areaId2_input" placeholder="请输入收费标准名称" autocomplete="off"/>
                                    -->
                                    <select id="areaId2_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">包车收费:</label>
                                <div class="col-sm-8">
                                    <!--
                                    <input type="hidden" id="baocheAreaId2">
                                    <input type="text" class="form-control" id="baocheAreaId2_input" placeholder="请输入收费标准名称" autocomplete="off"/>
                                    -->
                                    <select id="baocheAreaId2_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">寄货收费:</label>
                                <div class="col-sm-8">
                                    <!--
                                    <input type="hidden" id="jihuoAreaId2">
                                    <input type="text" class="form-control" id="jihuoAreaId2_input" placeholder="请输入收费标准名称" autocomplete="off"/>
                                    -->
                                    <select id="jihuoAreaId2_input" class="form-control"></select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话:</label>
                                <div class="col-sm-8">
                                    <input id="editContactNumber" class="form-control"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                </div>
                                <div class="col-sm-3">
                                    <input type="button" class="btn btn-primary" id="update" value="修改">
                                    <button type="button" class="btn btn-default" data-dismiss="modal"
                                            id="close_modal_update">取消
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</@override>
<@override name="footer">
    <script type="text/javascript">
        var isMainCompany = false;
        <@shiro.isMainCompany>
        isMainCompany = true;
        </@shiro.isMainCompany>
    </script>
    <script src="${ctx}/assets/js/ajaxfileupload.js"></script>
    <script src="${ctx}/assets/js/jquery.paging.min.js"></script>
    <script src="${ctx}/assets/js/jquery.cityselect.js"></script>
    <script src="${ctx}/assets/js/jquery.autocomplete.js"></script>
    <script src="${ctx}/assets/js/zhuanxian/line.js"></script>
    <script src="${ctx}/assets/js/chosen.jquery.min.js"></script>
    <script type="text/javascript">
        function autoCom(address, city){
            $(address).AutoComplete({
                'data': "${ctx}/weixinmanager/getAddress",
                ajaxDataType: 'json',
                ajaxParams:function(keyword){
                    var str = city + " option:selected";
                    return {'city':$(str).text()};
                },
                'width': 'auto',
                'async': false,
                'listStyle': 'custom',
                'emphasis': false,
                'matchHandler': function(keyword, data){
                    return true;
                },
                'createItemHandler': function(index, data){
                    return "<span>"+data.name+"</span>";
                },
                'afterSelectedHandler': function(data){
                    $(address).val(data.name);
                }
            }).AutoComplete('show');
        }
        $.initProv("#prov", "#city");
        autoCom('#startAddress','#city');
        $.initProv("#end_prov", "#end_city");
        autoCom('#endAddress','#end_city');
        $.initProv("#prov2", "#city2");
        autoCom('#startAddress2','#city2');
        $.initProv("#end_prov2", "#end_city2");
        autoCom('#endAddress2','#end_city2');
        //改变地区
        $("#city").change(function () {
            $("#provName").val($("#prov option:selected").text());
            $("#cityName").val($("#city option:selected").text());
        });
        $("#end_city").change(function () {
            $("#provName").val($("#end_prov option:selected").text());
            $("#cityName").val($("#end_city option:selected").text());
        });
        //改变地区
        $("#city2").change(function () {
            $("#provName").val($("#prov2 option:selected").text());
            $("#cityName").val($("#city2 option:selected").text());
        });
        $("#end_city2").change(function () {
            $("#provName").val($("#end_prov2 option:selected").text());
            $("#cityName").val($("#end_city2 option:selected").text());
        });

        var thisButton;

        function deleteLine() {
            if (thisButton.attr("data-value").trim() == null || thisButton.attr("data-value").trim() == "") {
                $.scojs_message("车辆类型不存在！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            $.get('${ctx}/zhuanxian/deleteLine', {'id': thisButton.attr("data-value")}, function (data) {
                if (data.success) {
                    thisButton.parent().parent().remove();

                    $.scojs_message('线路删除成功', $.scojs_message.TYPE_OK);
                    setTimeout(function () {
                        window.location.reload(true);
                    }, 300);
                } else {
                    $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
                }
            }, 'json');
        }

        $(document).ready(function () {
            $(document).on("click", ".deletethis", function () {
                thisButton = $(this);
                var confirm = $.scojs_confirm({
                    content: "你真的要删除该类型吗？",
                    action: deleteLine
                });
                confirm.show();
            });

            $("input").bind("input propertychange", function () {
                var val = $(this).val();
                if (val.length > 20) {
                    $.scojs_message('内容过长', $.scojs_message.TYPE_ERROR);
                    $(this).val(val.substring(0, 21));
                }
            });


        });


        //添加汽车类型
        $(document).on("click", ".addLine", function () {
            $('#dialog_line').modal();
        });


        $(document).on("click", "#save", function () {
            var roleIds = '';
            $(".roleInput").each(function(){
                if(this.checked){
                    roleIds += $(this).val();
                    roleIds += ",";
                }
            });
            roleIds = roleIds.substring(0,roleIds.length-1);
            var name = $('#firstName').val().trim() + '-' + $('#lastName').val().trim();
            console.log(name);
            var prov = $("#prov").val();
            var city = $("#city").val();
            var end_prov = $("#end_prov").val();
            var end_city = $("#end_city").val();
            //联系电话
            var contactNumber = $("#contactNumber").val();

            if (prov == "" || city == "") {
                $.scojs_message("请选择开始城市", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var startCity = $("#prov").find("option:selected").text() + "-" + $("#city").find("option:selected").text();
            if ($("#startAddress").val() == null || $("#startAddress").val() == "") {
                $.scojs_message("请填写开始地址", $.scojs_message.TYPE_ERROR);
                return false;
            }

            if (end_prov == "" || end_city == "") {
                $.scojs_message("请选择目的地城市", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($("#endAddress").val() == null || $("#endAddress").val() == "") {
                $.scojs_message("请填写目的地地址", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var endCity = $("#end_prov").find("option:selected").text() + "-" + $("#end_city").find("option:selected").text();
            if (name == null || name == "") {
                $.scojs_message("路线名称不能为空", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($('#areaId_input').val() == null || $('#areaId_input').val().trim() == "") {
                $.scojs_message("请选择拼车收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($('#baocheAreaId_input').val() == null || $('#baocheAreaId_input').val().trim() == "") {
                $.scojs_message("请选择包车收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($('#jihuoAreaId_input').val() == null || $('#jihuoAreaId_input').val().trim() == "") {
                $.scojs_message("请选择寄货收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            $('#dialog_Line').modal("hide");
            $.post('${ctx}/zhuanxian/createLine',
                {
                    'companyId': $('#companyId').val(), 'companyName': $('#companyId').find("option:selected").text(),
                    'name': name,
                    'startCity': startCity,
                    'startAddress': $('#startAddress').val(),
                    'endCity': endCity,
                    'endAddress': $('#endAddress').val(),
                    'areaId': $('#areaId_input').val(),
                    'baocheAreaId': $('#baocheAreaId_input').val(),
                    'jihuoAreaId': $('#jihuoAreaId_input').val(),
                    'contactNumber': contactNumber,
                    'roleId': ''==roleIds?null:roleIds,
                },
                function (data) {
                    if (data.success) {
                        $.scojs_message(data.message, $.scojs_message.TYPE_OK);
                        setTimeout(function () {
                            window.location.reload(true);
                        }, 500);
                    } else {
                        $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
                    }
                }, 'json');
        });
        $("#close_modal_memo").click(function () {
            $('#dialog_Line').modal("hide");
        });

        //修改线路

        $(document).on("click", ".updateLine", function () {
            $("#lineId2").val($(this).attr('lineId'));
            $("#name2").val($(this).attr('name'));
            $("#startAddress2").val($(this).attr('startAddress'));
            $("#endAddress2").val($(this).attr('endAddress'));
            $("#editContactNumber").val($(this).attr('contactNumber'));
            var areaId = $(this).attr('areaId');
            var baocheAreaId = $(this).attr("baocheAreaId");
            var jihuoAreaId = $(this).attr("jihuoAreaId");

            var areaName = $(this).attr('areaName');
            var baocheAreaName = $(this).attr("baocheAreaName");
            var jihuoAreaName = $(this).attr("jihuoAreaName");

            //$("#areaId2").val(areaId);
            //$("#baocheAreaId2").val(baocheAreaId);
            //$("#jihuoAreaId2").val(jihuoAreaId);

            //$("#areaId2_input").val(areaName);
            //$("#baocheAreaId2_input").val(baocheAreaName);
            //$("#jihuoAreaId2_input").val(jihuoAreaName);

            $.ajax({
                url: '${ctx}/zhuanxian/linesData',
                type: 'GET',
                async: false,
                dataType: 'json',
                data: {},
                success: function (result) {
                    //生成各个收费标准的option，并选中值
                    var areaSelect = getAreaContentSelected(result, areaId);
                    $("#areaId2_input").html(areaSelect).chosen().change(function () {
                    });
                    $("#areaId2_input option").each(function (index, element) {
                        var flag = false;
                        if ($(element).attr("selected") == "selected") {
                            $("#areaId2_input").next().find("a").text(areaName);
                            return false;
                        }
                        if (!flag) {
                            $("#areaId2_input").next().find("a").html("<em>请选择收费标准</em>");
                        }
                    });
                    var baocheAreaSelect = getAreaContentSelected(result, baocheAreaId);
                    $("#baocheAreaId2_input").html(baocheAreaSelect).chosen().change(function () {
                    });
                    $("#baocheAreaId2_input option").each(function (index, element) {
                        var flag = false;
                        if ($(element).attr("selected") == "selected") {
                            $("#baocheAreaId2_input").next().find("a").text(baocheAreaName);
                            return false;
                        }
                        if (!flag) {
                            $("#baocheAreaId2_input").next().find("a").html("<em>请选择收费标准</em>");
                        }
                    });
                    var jihuoAreaSelect = getAreaContentSelected(result, jihuoAreaId);
                    $("#jihuoAreaId2_input").html(jihuoAreaSelect).chosen().change(function () {
                    });
                    $("#jihuoAreaId2_input option").each(function (index, element) {
                        var flag = false;
                        if ($(element).attr("selected") == "selected") {
                            $("#jihuoAreaId2_input").next().find("a").text(jihuoAreaName);
                            return false;
                        }
                        if (!flag) {
                            $("#jihuoAreaId2_input").next().find("a").html("<em>请选择收费标准</em>");
                        }
                    });
                    //收费标准下拉框选值变化，改变下拉框显示值
                    $(document).on("click", ".active-result", function () {
                        $($(this).parent().parent().parent().children()[0]).html($(this).text())
                    });
                }
            });


            var prov = $(this).attr('startCity').split("-")[0]
            var city = $(this).attr('startCity').split("-")[1]
            var end_prov = $(this).attr('endCity').split("-")[0]
            var end_city = $(this).attr('endCity').split("-")[1]
            $("#prov2 option").each(function (index, element) {
                if ($(element).text() == prov) {
                    $(element).attr("selected", "selected");
                    $("#prov2").change();
                    return false;
                }
            });
            $("#city2 option").each(function (index, element) {
                if ($(element).text() == city) {
                    $(element).attr("selected", "selected");
                    return false;
                }
            });
            $("#end_prov2 option").each(function (index, element) {
                if ($(element).text() == end_prov) {
                    $(element).attr("selected", "selected");
                    $("#end_prov2").change();
                    return false;
                }
            });
            $("#end_city2 option").each(function (index, element) {
                if ($(element).text() == end_city) {
                    $(element).attr("selected", "selected");
                    return false;
                }
            });

            $('#dialog_line_update').modal();


        });
        $(document).on("click", "#update", function () {
            console.log($("#editContactNumber").val())

            if ($('#name2').val().trim() == null || $('#name2').val().trim() == "") {
                $.scojs_message("线路名不能为空", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var prov = $("#prov2").val();
            var city = $("#city2").val();
            var end_prov = $("#end_prov2").val();
            var end_city = $("#end_city2").val();

            if (prov == "" || city == "") {
                $.scojs_message("请选择开始城市", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($("#startAddress2").val() == null || $("#startAddress2").val() == "") {
                $.scojs_message("请填写开始地址", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var startCity = $("#prov2").find("option:selected").text() + "-" + $("#city2").find("option:selected").text();
            if (end_prov == "" || end_city == "") {
                $.scojs_message("请选择目的地城市", $.scojs_message.TYPE_ERROR);
                return false;
            }
            if ($("#endAddress2").val() == null || $("#endAddress2").val() == "") {
                $.scojs_message("请填写目的地地址", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var endCity = $("#end_prov2").find("option:selected").text() + "-" + $("#end_city2").find("option:selected").text();

            var pincheAreaText = $("#areaId2_input").next().find("a").text();
            if ($('#areaId2_input').val() == null || pincheAreaText == "请选择收费标准") {
                $.scojs_message("请选择拼车收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var pincheAreaText = $("#baocheAreaId2_input").next().find("a").text();
            if ($('#baocheAreaId2_input').val() == null || pincheAreaText == "请选择收费标准") {
                $.scojs_message("请选择包车收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            var jihuoAreaText = $("#jihuoAreaId2_input").next().find("a").text();
            if ($('#jihuoAreaId2_input').val() == null || jihuoAreaText == "请选择收费标准") {
                $.scojs_message("请选择寄货收费标准！", $.scojs_message.TYPE_ERROR);
                return false;
            }
            $('#dialog_line_update').modal("hide");
            $.post('${ctx}/zhuanxian/updateLine',
                {
                    'lineId': $('#lineId2').val(),
                    'name': $('#name2').val(),
                    'startCity': startCity,
                    'startAddress': $('#startAddress2').val(),
                    'endCity': endCity,
                    'endAddress': $('#endAddress2').val(),
                    'areaId': $('#areaId2_input').val(),
                    'baocheAreaId': $('#baocheAreaId2_input').val(),
                    'jihuoAreaId': $('#jihuoAreaId2_input').val(),
                    'contactNumber': $('#editContactNumber').val()
                },
                function (data) {
                    if (data.success) {
                        $.scojs_message(data.message, $.scojs_message.TYPE_OK);
                        setTimeout(function () {
                            window.location.reload(true);
                        }, 1000);
                    } else {
                        $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
                    }
                }, 'json');
        });
        $("#close_modal_update").click(function () {
            $('#dialog_line_update').modal("hide");
        });

        function getAreaContentSelected(result, id) {

            var areaContent = '';
            var areaList = result.areaList;
            $(areaList).each(function (index, data) {
                if (id == data.id) {
                    areaContent += "<option value='" + data.id + "' selected='selected'>" + data.name + "</option>"
                } else {
                    areaContent += "<option value='" + data.id + "'>" + data.name + "</option>"
                }

            });
            return areaContent;
        };

    </script>
</@override>
<@extends name="../layout.ftl"/>
